package java编程思想.第18章._9_进程控制;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class OSExecute {
	static void command(String command) {
		try {
			Process process = new ProcessBuilder(command.split(" ")).start();
			BufferedReader results = new BufferedReader(new InputStreamReader(process.getInputStream(), "gbk"));
			String s;
			while ((s = results.readLine()) != null)
				System.out.println(s);
			BufferedReader errors = new BufferedReader(new InputStreamReader(process.getErrorStream()));
			while ((s = errors.readLine()) != null) {
				System.err.println(s);
			}
		} catch (Exception e) {
		}
	}

	public static void main(String[] args) {
		command("ipconfig");
	}

}
